% plot the estimates 

tic
cd(folder_data)
load est_Mis.mat LL_ST_est LL_TT_est theta_true M P J I

dim = 1; % focus on the first coefficient
true = theta_true(dim);

formatSpec = 'fig_1_%d';
% figSpec = 'subfig (%d)';

% LL_ST_est LL_TT_est % nparam x M*P

% P = size(LL_ST_est,2)/M;

% plot distributions for the first dimension: dim = 1
cd(folder_figures)
for pp = 1:P
    [f,xi] = ksdensity(LL_TT_est(dim,1+M*(pp-1):M+M*(pp-1)));
    [g,yi] = ksdensity(LL_ST_est(dim,1+M*(pp-1):M+M*(pp-1)));
    
    % figname = sprintf(figSpec, pp);
    figure()
    plot(yi,g,':b','LineWidth',4);
    hold on
    plot(xi,f,'-r','LineWidth',3);
    hold on
    line([true, true], [100 0],'LineWidth',1.5); %legend('off');
    if pp == 1
    l = legend({'Stability Estimates', 'WTT Estimates'},'Box','off','Location','northwest');
    set(l,'FontSize',20);
    end
    %title(figname)
    ax = gca; % current axes
    ax.FontSize = 25;
    ax.TickDir = 'out';
    ax.TickLength = [0.02 0.02];
    ax.YLim = [0 100];
    ax.XLim = [-0.35+true 0.35+true];
    filename = sprintf(formatSpec, pp);
    print(filename,'-djpeg')
    print(filename,'-depsc2')
end

close all
toc 